<template>
  <el-dialog :visible.sync="show" title="修改信息" width="30%">
    <div class="hidden-sm-and-down">
      <el-form ref="elForm" :model="updateForm" :rules="rules" label-width="100px" size="medium">
        <!-- <el-form-item  label="主键"  prop="id">
            <el-input v-model="updateForm['id']" style="width: 100%"
                      clearable placeholder="请输入主键">
            </el-input>
        </el-form-item> -->
        <el-form-item label="活动名称" prop="eventName">
          <el-input v-model="updateForm['eventName']" style="width: 100%"
                    clearable placeholder="请输入活动名称">
          </el-input>
        </el-form-item>
        <el-form-item label="创始人id" prop="proprieterId">
          <el-input v-model="updateForm['proprieterId']" style="width: 100%"
                    clearable placeholder="请输入创始人id">
          </el-input>
        </el-form-item>
        <el-form-item label="所属社团id" prop="organizationId">
          <el-input v-model="updateForm['organizationId']" style="width: 100%"
                    clearable placeholder="请输入所属社团id">
          </el-input>
        </el-form-item>
        <el-form-item label="活动类型" prop="type">
          <el-input v-model="updateForm['type']" style="width: 100%"
                    clearable placeholder="请输入活动类型">
          </el-input>
        </el-form-item>
        <el-form-item label="活动信息" prop="introduce">
          <el-input v-model="updateForm['introduce']" style="width: 100%"
                    clearable placeholder="请输入活动信息">
          </el-input>
        </el-form-item>
        <el-form-item label="图片id" prop="imgId">
          <el-input v-model="updateForm['imgId']" style="width: 100%"
                    clearable placeholder="请输入图片id">
          </el-input>
        </el-form-item>
        <el-form-item label="最大限制人数" prop="peopleNumber">
          <el-input v-model="updateForm['peopleNumber']" style="width: 100%"
                    clearable placeholder="请输入最大限制人数">
          </el-input>
        </el-form-item>
        <el-form-item label="是否签到" prop="signIn">
          <el-input v-model="updateForm['signIn']" style="width: 100%"
                    clearable placeholder="请输入是否签到">
          </el-input>
        </el-form-item>
        <!-- <el-form-item  label="开始时间"  prop="startTime">
            <el-input v-model="updateForm['startTime']" style="width: 100%"
                      clearable placeholder="请输入开始时间">
            </el-input>
        </el-form-item>
        <el-form-item  label="结束时间"  prop="endTime">
            <el-input v-model="updateForm['endTime']" style="width: 100%"
                      clearable placeholder="请输入结束时间">
            </el-input>
        </el-form-item> -->
        <el-form-item label="活动主题" prop="name">
          <el-input v-model="updateForm['name']" style="width: 100%"
                    clearable placeholder="请输入活动主题">
          </el-input>
        </el-form-item>

        <!-- <el-form-item  label="创建人的电话"  prop="phonenumber">
            <el-input v-model="updateForm['phonenumber']" style="width: 100%"
                      clearable placeholder="请输入创建人的电话">
            </el-input>
        </el-form-item> -->
        <el-form-item label="活动地点" prop="address">
          <el-input v-model="updateForm['address']" style="width: 100%"
                    clearable placeholder="请输入活动地点">
          </el-input>
        </el-form-item>
        <el-form-item label="活动所属部门" prop="department">
          <el-input v-model="updateForm['department']" style="width: 100%"
                    clearable placeholder="请输入活动所属部门">
          </el-input>
        </el-form-item>
        <el-form-item label="经度" prop="longitude">
          <el-input v-model="updateForm['longitude']" style="width: 100%"
                    clearable placeholder="请输入经度">
          </el-input>
        </el-form-item>
        <el-form-item label="维度" prop="latitude">
          <el-input v-model="updateForm['latitude']" style="width: 100%"
                    clearable placeholder="请输入维度">
          </el-input>
        </el-form-item>
        <el-form-item size="large">
          <el-button type="primary" @click="submitForm">提交</el-button>
          <el-button @click="resetForm">重置</el-button>
          <el-button type="primary" @click="eventUpdateClose">取消</el-button>
          <br>
          <span style="color: #00ffff;">{{ message }}</span>
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>
</template>
<script>
import {updateEvent} from "@/api/eventServer";

export default {
  name: 'eventUpdate',
  components: {},
  data() {
    return {
      show: false,
      updateForm: {
        "id": null,
        "proprieterId": null,
        "organizationId": null,
        "type": null,
        "introduce": null,
        "imgId": null,
        "peopleNumber": null,
        "signIn": null,
        // "startTime":null,
        // "endTime":null,
        "name": null,
        "eventName": null,
        "phonenumber": null,
        "address": null,
        "department": null,
        "longitude": null,
        "latitude": null,
      },
      msg: {
        "id": null,
        "proprieterId": null,
        "organizationId": null,
        "type": null,
        "introduce": null,
        "imgId": null,
        "peopleNumber": null,
        "signIn": null,
        // "startTime":null,
        // "endTime":null,
        "name": null,
        "eventName": null,
        "phonenumber": null,
        "address": null,
        "department": null,
        "longitude": null,
        "latitude": null,
      },
      message: '',
      id: 0,
      rules: {},
    }
  },
  computed: {},
  mounted() {
    this.$bus.$on('eventUpdateOpen', this.eventUpdateOpen)      // 显示更新会话
    this.$bus.$on('eventUpdateClose', this.eventUpdateClose)    // 关闭更新会话
  },
  beforeCreate() {
    this.$bus.$off('eventUpdateOpen')
    this.$bus.$off('eventUpdateClose')
  },
  methods: {
    //提交成功提示
    open1() {
      this.$notify({
        title: '成功',
        message: '修改成功',
        type: 'success'
      });
    },
    eventUpdateOpen(msg) {
      this.msg = msg
      this.resetForm()
      this.show = true
    },
    eventUpdateClose() {
      this.show = false
    },
    // 提交表单
    submitForm() {
      updateEvent(this.updateForm).then(response => {
        response    // 处理响应
        // 更新成功，提交表格
        this.$bus.$emit('eventUpDataTable', this.Value)
        this.open1()
      })
    },
    // 重置表单
    resetForm() {
      this.updateForm.id = this.msg["id"]
      this.updateForm.proprieterId = this.msg["proprieterId"]
      this.updateForm.organizationId = this.msg["organizationId"]
      this.updateForm.type = this.msg["type"]
      this.updateForm.introduce = this.msg["introduce"]
      this.updateForm.imgId = this.msg["imgId"]
      this.updateForm.peopleNumber = this.msg["peopleNumber"]
      this.updateForm.signIn = this.msg["signIn"]
      // this.updateForm.startTime = this.msg["startTime"]
      // this.updateForm.endTime = this.msg["endTime"]
      this.updateForm.name = this.msg["name"]
      this.updateForm.eventName = this.msg["eventName"]
      this.updateForm.phonenumber = this.msg["phonenumber"]
      this.updateForm.address = this.msg["address"]
      this.updateForm.department = this.msg["department"]
      this.updateForm.longitude = this.msg["longitude"]
      this.updateForm.latitude = this.msg["latitude"]
    },
  }
}
</script>
<style>
.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
</style>
